package com.dqp.cslggroup.UI;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.TextView;
import com.dqp.cslggroup.R;

public class menuAdapter extends BaseAdapter {
    int[] logos = new int[]{
            R.string.icon_jwxt, R.string.icon_time,
            R.string.icon_exam, R.string.icon_settings, R.string.icon_about

    };
    //R.string.icon_exam, R.string.icon_find,
    String[] titles = new String[]{
            "教务系统", "上课提醒",
            "综测查询", "应用设置", "关于应用"
    };

    Context context;

    //构造方法"等级考试", "失物招领",
    public menuAdapter(Context context) {
        this.context = context;
    }

    //获得数量
    public int getCount() {
        return titles.length;
    }

    //获得当前选项
    public Object getItem(int item) {
        return item;
    }

    //获得当前选项id
    public long getItemId(int id) {
        return id;
    }

    @Override

    //创建View方法
    public View getView(int position, View convertView, ViewGroup parent) {
        @SuppressLint("ViewHolder") View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.gridview_item, parent, false);
        GridView gridView = view.findViewById(R.id.menu_grid);
        TextView title = view.findViewById(R.id.menu_title);
        IconView logo = view.findViewById(R.id.menu_logo);
        title.setText(titles[position]);
        logo.setText(context.getResources().getString(logos[position]));
        return view;
    }

    @Override
    public void notifyDataSetChanged() {
        super.notifyDataSetChanged();
    }
}
